<!DOCTYPE html>
<html>

<!-- Head -->
<head>
    <title>注册页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="application/x-javascript"> addEventListener("load", function () {
        setTimeout(hideURLbar, 0);
    }, false);

    function hideURLbar() {
        window.scrollTo(0, 1);
    } </script>
    <link rel="stylesheet" href="css/loginRegister.css" type="text/css" media="all">
</head>

<body>

<h1>springboot学习系统</h1>

<div class="container">
    <div class="login">
        <h2>员工登录</h2>
        <div class="form">
            <input type="text"  placeholder="请输入员工邮箱" v-model="email">
            <button class="sendCode" @click="getEmailCode">发送验证码</button>
            <input type="text" placeholder="验证码" v-model="code">
            <button class="loginBtn" @click="login">登录</button>
        </div>
    </div>
</div>

<script src="./js/vue.min.js"></script>
<script src="./js/axios.min.js"></script>
<link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.3/theme-chalk/index.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.3/index.js"></script>
</body>
<script>
    new Vue({
        el:".login",
        data:{
            email:"480694856@qq.com",
            code:"",
        },
        methods:{
            getEmailCode(){
                axios.get(`getEmailCode?email=`+this.email).then(resp=>{
                    this.$notify({
                        title: '成功',
                        message: '发送成功',
                        type: 'success'
                    });
                    if (resp.data===true){
                        this.$notify({
                            title: '成功',
                            message: '发送邮件成功',
                            type: 'success'
                        });
                    }else {
                        this.$notify.error({
                            title: '错误',
                            message: '发送邮件失败'
                        });
                    }
                });
            },
            login(){
                axios.post(`login?email=`+this.email+"&code="+this.code).then(resp=>{
                    if (resp.data===true){
                        this.$notify({
                            title: '成功',
                            message: '登录成功',
                            type: 'success'
                        });
                        location.href="/index.html"
                    }else {
                        this.$notify.error({
                            title: '错误',
                            message: '登录失败'
                        });
                    }
                });
            }

        }
    })
</script>

</html>
